ActionController::Routing::Routes.draw do |map|

  
  map.resources :invitations
  map.resources :adverts, :only=>[], :member=>{:script=>:get}
  
  map.resources :users do |user|
    user.resources :videos, :except=>[:edit, :update]
    #user.resources :campaigns, :only=>[:index], :as=>{:index=>:user_campaigns}
  end
  map.user_campaigns "/users/:user_id/campaigns", :controller => "campaigns", :action => "campaigns_for_user"
  
  map.resources :videos, :only=>[:show, :index], :member=>{:vote=>:post, :comment=>:post} do |video|
    video.resources :comments, :only=>[:destroy], :controller=>"video_comments"
  end
  
  map.resources :campaigns, :only=>[:index, :show], :member=>{:join_page=>:get, :all_participants=>:get, :participants=>:get, :join=>:post}, :collection=>{:ended=>:get, :upcoming=>:get}
  
  map.resources :pages, :only=>[:show]
  
  map.publishs_stream_to_vote_comment 'user/:id/publishstreamtovotecomment', :controller=>"users", :action=>"invite_friends_to_vote_and_comment"
  
  map.page_permalink 'page/:permalink', :controller=>"pages", :action=>"permalink"
  map.discover_video_info 'video/discover_video_info', :controller=>"videos", :action=>"discover_video_info"
  
  #User Activation Route
  map.activate 'user/activate/:id/:activation_key', :controller => "users", :action => "activate"
  map.reset_password 'user/reset_password/:id/:key', :controller=>"users", :action=>"reset_password" 
  map.recover_password 'user/recover_password', :controller=>"users", :action=>"recover_password"
  map.register_fb_user 'user/register_fb_user', :controller=>"users", :action=>"register_fb_user"
  #New session route
  
  
  
  map.new_session 'sessions/new', :controller=>"sessions", :action=>"new"
  
  map.site_proxy '/proxysite', :controller=>"site_proxy", :action=>"proxy"

  #Facebooker
  map.connect '/fb/:action', :controller => 'fb_connect'
  
  #admin
  #map.admin '/admin', :controller=>"admin", :action=>"index"
  map.admin 'admin', :controller => :admin, :action => :index
  map.namespace(:admin) do |admin|
    admin.resources :menus
    admin.resources :pages
    admin.resources :page_menu_options
    admin.resources :campaigns, :member=>{:copy=>:get}, :collection=>{:ended=>:get}
    admin.resources :site_configurations, :except=>[:show]
    admin.resources :adverts
    admin.resources :campaign_adverts
    
  end
  
  # The priority is based upon order of creation: first created -> highest priority.

  # Sample of regular route:
  #   map.connect 'products/:id', :controller => 'catalog', :action => 'view'
  # Keep in mind you can assign values other than :controller and :action

  # Sample of named route:
  #   map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
  # This route can be invoked with purchase_url(:id => product.id)

  # Sample resource route (maps HTTP verbs to controller actions automatically):
  #   map.resources :products

  # Sample resource route with options:
  #   map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }

  # Sample resource route with sub-resources:
  #   map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
  
  # Sample resource route with more complex sub-resources
  #   map.resources :products do |products|
  #     products.resources :comments
  #     products.resources :sales, :collection => { :recent => :get }
  #   end

  # Sample resource route within a namespace:
  #   map.namespace :admin do |admin|
  #     # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
  #     admin.resources :products
  #   end

  # You can have the root of your site routed with map.root -- just remember to delete public/index.html.
  # map.root :controller => "welcome"

  # See how all your routes lay out with "rake routes"

  # Install the default routes as the lowest priority.
  # Note: These default routes make all actions in every controller accessible via GET requests. You should
  # consider removing or commenting them out if you're using named routes and resources.
  map.connect ':controller/:action/:id'
  map.connect ':controller/:action/:id.:format'

  #Home route
  map.root :controller => "home"

end
